<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  我是字体的演示2
  <div id='box'>
    <button size="16">按钮1</button>
    <button size="20">按钮2</button>
    <button size="30">按钮3</button>
  </div>
    
  <script>
    var box = document.getElementById('box')
    var btns = box.children

    function makeFunction(size){
      return function(){
        document.body.style.fontSize = size + 'px'
      }
    }

    for ( var i = 0; i < btns.length; i++){
      var btn = btns[i]
      // 获取标签的自定义属性
      var size = btn.getAttribute('size')
      btn.onclick = makeFunction(size)
    }


  </script>
</body>
</html>